requireViewById

open fun <T : View?> requireViewById(@NonNull view: View, @IdRes id: Int): T(source)

Finds the first descendant view with the given ID, the view itself if the ID matches getId, or throws an IllegalArgumentException if the ID is invalid or there is no matching view in the hierarchy.

Note: In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.

Return

a view with given ID

Parameters

view

the view to start the search from.

id

the ID to search for

See also